package com.forum.module.system.controller.admin.user.vo.user;

import com.forum.framework.common.pojo.PageParams;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Objects;

import static com.forum.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;

/**
 * 管理后台 - 用户分页 请求视图
 *
 * @author zihan.ouyang
 */
@Schema(description = "管理后台 - 用户分页 请求视图")
public class UserPageReqVO extends PageParams {
    @Schema(description = "用户账号，模糊匹配", example = "zihan.ouyang")
    private String username;

    @Schema(description = "手机号码，模糊匹配", example = "15601691300")
    private String mobile;

    @Schema(description = "状态，参见 CommonStatusEnum 枚举", example = "1")
    private Integer status;

    @Schema(description = "创建时间范围", type = "array", example = "['2022-07-08 00:00:00', '2022-07-09 23:59:59']")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime[] createTime;

    public UserPageReqVO() {
    }

    public UserPageReqVO(String username, String mobile, Integer status, LocalDateTime[] createTime) {
        this.username = username;
        this.mobile = mobile;
        this.status = status;
        this.createTime = createTime;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public LocalDateTime[] getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime[] createTime) {
        this.createTime = createTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserPageReqVO that = (UserPageReqVO) o;
        return Objects.equals(username, that.username) && Objects.equals(mobile, that.mobile) && Objects.equals(status, that.status) && Objects.deepEquals(createTime, that.createTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(username, mobile, status, Arrays.hashCode(createTime));
    }
}
